import {useReducer} from 'react'
//引入reducer
import reducer from './reducer';

export default  ()=>{
    //state 状态值
    //dispatch :派发者 （函数）
    const [state, dispatch] = useReducer(reducer,{num:100});

    return(
        <>
          <h1>值为：{state.num}</h1>
          <button onClick={()=>{dispatch({type:"jia"})}}>加1</button>
          <button onClick={()=>{dispatch({type:"jian"})}}>减1</button>
          <button onClick={()=>{dispatch({type:"cheng"})}}>乘*2</button>
          <button onClick={()=>{dispatch({type:"chu"})}}>除2</button>
        </>
    )
    
}